package org.ubc.cs410.disposal2020;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;

import com.google.gwt.maps.client.geom.LatLng;

/*
 * Garbage Class
 * In the game, user controls robots to collect garbage and accumulate points
 * Garbage will have an amount field associated with it, which specifies how heavy the piece of garbage is
 * The heavier it is, the more points a user can accumulate
 */

public class Garbage implements Serializable, HasLocation {
	private static final long serialVersionUID = 6471621639977921259L;

	private double latitude;
	private double longitude;

	private int amount;

	public Garbage() {

	}

	public Garbage(double latitude, double longitude, int amount) {
		this.latitude = latitude;
		this.longitude = longitude;
		this.amount = amount;
	}

	public static Garbage generateGarbage(BuildingBoundary bb, int amount) {
		List<Float> lats = bb.getLatitudes();
		List<Float> lngs = bb.getLongitudes();	  
		// Try to find building centre
		float latsum = 0;
		float longsum = 0;
		int size = lats.size();
		for (int i = 0; i < size; i++) {
			latsum += lats.get(i);
			longsum += lngs.get(i);
		}
		latsum = latsum / size;
		longsum = longsum / size;

		return new Garbage(latsum, longsum, amount);
	}

	@Override
	public double getLatitude() {
		return latitude;
	}

	@Override
	public double getLongitude() {
		return longitude;
	}

	public int getAmount() {
		return this.amount;

	}
}
